﻿@inject Eqwww.App.Identity.UserApp UserApp
@inject Eqwww.Config.IAppConfigProvider AppConfigProvider

@{
    var appConfig = AppConfigProvider.Load();

    var userModel = UserApp.GetUserAsync(User).Result;

    var appBarCss = "mdui-color-theme";
    if (appConfig.WhiteAppbar)
    {
        appBarCss = "mdui-color-white";
    }

}
<!DOCTYPE html>

<html>
<head>
    <meta name="viewport" content="width=device-width" />
    <title>@appConfig.AppName</title>
    <meta name="description" content="@appConfig.MetaDescription">
    <meta name="keywords" content="@appConfig.MetaKeywords">
    <link rel="icon" type="image/png" href="~/images/logo.png">
    <link rel="icon" sizes="192x192" href="~/images/logo.png">
    <link rel="stylesheet" type="text/css" href="~/lib/mdui/css/mdui.min.css" />
    <link rel="stylesheet" type="text/css" href="~/css/manage.css" asp-append-version="true" />
    <style type="text/css">
        body {
            padding-bottom: 80px;
        }
    </style>
</head>
<body class="mdui-theme-primary-@appConfig.DefaultThemeColor mdui-theme-accent-@appConfig.DefaultAccentColor mdui-color-grey-100  mdui-appbar-with-toolbar ">

    <header id="eq-header" class="mdui-appbar mdui-appbar-fixed mdui-shadow-1 @appBarCss">
        <div class="mdui-toolbar">
            <a href="~/" class="mdui-hidden mdui-btn mdui-btn-icon mdui-ripple "><i class="mdui-icon material-icons">home</i></a>
            <a class=" mdui-valign" href="~/">
                <img src="~/images/logo.png" style="height:40px;" />
            </a>

            <a href="javascript:;" id="eq-appbar-typo-title" class="mdui-typo-title">@ViewData["Title"]</a>
            <div id="eq-loading-spinner" class="mdui-spinner mdui-spinner-colorful" style="display:none;"></div>

            <div class="mdui-toolbar-spacer"></div>
            <a class="mdui-ripple mdui-hidden-sm-down" asp-controller="Home" asp-action="Index"><i class="mdui-icon material-icons">home</i></a>
            

            @if (User.Identity.IsAuthenticated && userModel != null)
            {


                <a href="javascript:;" class="mdui-ripple mdui-p-l-1 mdui-p-r-1 mdui-clearfix mdui-valign" mdui-menu='{ target: "#eqManageUserAction",covered:false }'>
                    <img src="@UserApp.GetAvatar(userModel)" class="mdui-img-circle mdui-img-fluid mdui-float-left" style="width:36px;" />
                    <span class="mdui-float-right mdui-m-l-1 mdui-hidden-sm-down">
                        @if (appConfig.RealNameFirst)
                        {
                            @(userModel.RealName ?? userModel.UserName)
                        }
                        else
                        {
                            @userModel.UserName
                        }
                    </span>
                    <i class="mdui-icon material-icons">keyboard_arrow_down</i>
                </a>
                <ul class="mdui-menu" id="eqManageUserAction">
                    <li class="mdui-menu-item">
                        <div class="mdui-text-center">
                            <img src="@UserApp.GetAvatar(userModel)" class="mdui-img-circle" style="width:128px;" />
                        </div>
                    </li>
                    <li class="mdui-menu-item">
                        <a href="javascript:;" class="mdui-ripple mdui-text-center">
                            @userModel.UserName
                        </a>
                    </li>
                    <li class="mdui-menu-item">
                        <a class="mdui-ripple" href="@Url.Action("Index", "Manage",new { area=""})">
                            <i class="mdui-menu-item-icon mdui-icon material-icons">dashboard</i>进入系统
                        </a>
                    </li>
                    <li class="mdui-menu-item">
                        <a href="javascript:;" onclick="btn_logout()" class="mdui-ripple">
                            <i class="mdui-menu-item-icon mdui-icon material-icons">arrow_forward</i>退出登录
                        </a>
                        @Html.AntiForgeryToken()
                    </li>
                </ul>

            }
            else
            {
                <a class="nav-link text-dark" asp-area="Identity" asp-page="/Account/Login"><i class="mdui-icon material-icons">account_circle</i></a>
            }
        </div>

    </header>

    <div class="mdui-container-fluid">
        @RenderBody()
    </div>
    
    

    <div class="mdui-container-fluid ">
        <div class="" style="position:fixed;bottom:0;left:0;width:100%;">
            <div class="mdui-p-a-1 mdui-text-color-grey mdui-text-center">
                <p>Eqwww.EntityFrameworkCore @appConfig.AppVersion  Based on Asp.Net Core 3.1</p>
            </div>
        </div>
    </div>

    <div id="loadingBox">
        <div class="mdui-card">
            <div class="mdui-card-content mdui-valign">
                <div class="mdui-spinner mdui-spinner-colorful"></div>
                <div id="loadingContent" class="mdui-m-l-2">加载中,请稍候...</div>
            </div>
        </div>
    </div>

    <script src="~/lib/jquery/dist/jquery.min.js"></script>
    <script src="~/lib/jquery-cookie/jquery.cookie.js"></script>
    <script src="~/lib/mdui/js/mdui.min.js"></script>
    <script src="~/lib/layer/layer.js"></script>
    <script src="~/js/layerconfig.js" asp-append-version="true"></script>


    <script src="~/js/manage/manage.js" asp-append-version="true"></script>
    <script src="~/js/manage/modal.js" asp-append-version="true"></script>
    @RenderSection("Scripts", required: false)

    <script>

        


        function btn_logout()
        {
            var postdata={};
            if ($('[name=__RequestVerificationToken]').length > 0) {
                postdata["__RequestVerificationToken"] = $('[name=__RequestVerificationToken]').val();
            }

            $.loading(false);

            $.ajax({
                url:'/Identity/Account/Logout',
                type:'post',
                data:postdata,
                dataType:'json',
                success:function(data)
                {
                    if(data.state=='success')
                    {
                        $.snackbar('<i class="mdui-icon material-icons mdui-text-color-green">check</i> ' + data.message, data.state);
                        window.location.reload();
                    }
                    else{
                        $.loading(true);
                        $.modalAlert(data.message,'error');
                    }
                }
            })
        }
    </script>
</body>
</html>



